<template>
  <div style="width: 80%">
    <div style="margin-bottom: 30px">编辑用户</div>
    <el-form :inline="true" :model="form" label-width="100px">
      <el-form-item label="编号">
        <el-input v-model="form.id" disabled></el-input>
      </el-form-item>
      <el-form-item label="用户名">
        <el-input v-model="form.uname" disabled></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.upwd" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="form.utell" placeholder="手机号"></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="form.ustate" placeholder="用户状态"></el-input>
      </el-form-item>
      <el-form-item label="用户积分">
        <el-input v-model="form.uintegral" placeholder="请输入用户积分"></el-input>
      </el-form-item>
      <el-form-item label="会员等级">
        <el-input v-model="form.urole" placeholder="请输入会员等级"></el-input>
      </el-form-item>
    </el-form>

    <div style="text-align: center; margin-top: 30px">
      <el-button type="primary" @click="save" size="medium">提交</el-button>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: 'EditUser',
  data() {
    return {
      form: {

      }
    }
  },
  created() {
    const id = this.$route.query.id
    request.get("/user/" + id).then(res => {
      this.form = res.data
    })
  },
  methods: {
    save() {
      request.put('/user/update', this.form).then(res => {
        if (res.code === '200') {
          this.$notify.success('更新成功')
          this.$router.push("/userList")
        } else {
          this.$notify.error(res.msg)
        }
      })
    }
  }
}

</script>
